package com.global.test.chain.security.authentication;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.global.domain.Role;
import com.global.domain.User;
import com.global.emc.core.CoreUser;
import com.global.emc.core.exception.impl.EMCException;
import com.global.emc.security.authentication.RoleHandler;
import com.global.test.service.user.RoleService;

/**   
 *  
 * @Description:  [用一句话描述该文件做什么]   
 * @Author:       [Joly_Huang]   
 * @CreateDate:   [2014年3月20日 上午11:58:25]   
 * @UpdateUser:   [Joly_Huang]   
 * @UpdateDate:   [2014年3月20日 上午11:58:25]   
 * @UpdateRemark: [说明本次修改内容]  
 * @Version:      [v1.0] 
 *    
 */
@Component
public class RoleHandlerImpl implements RoleHandler {
	
	private RoleService roleService;
	
	public RoleService getRoleService() {
		return roleService;
	}
	@Resource
	public void setRoleService(RoleService roleService) {
		this.roleService = roleService;
	}


	@Override
	public void handlerRole(CoreUser coreUser) throws EMCException {
		User user = User.convertCoreUser(coreUser);
		List<Role> roles = roleService.getRoles(user);
		user.setRoles(roles);
	}

}
